﻿using FDEEPublicFunc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FDEEMain
{
    public partial class DeckSlabParaForm : Form
    {
        public double width = 0, length = 0;
        public FDEE.Model.eSubType eHeightType = FDEE.Model.eSubType.A;
        public int typeNum = 1;
        public int totalNum=1;
        public bool hasHole = false;
        public string pierParas = "";
        public string title = "";
        private bool isDec = true;
        public int NumHalfEJ=0, NumLink=0, NumHole = 0;
        public DeckSlabParaForm()
        {
            InitializeComponent();
            plL.Visible = true;
            plH.Visible = true;
            plYZB.Visible = false;
            cbLine.SelectedIndex = 0;
        }

        public DeckSlabParaForm(bool isDeck=true)
        {
            InitializeComponent();
            isDec = isDeck;
            cbLine.SelectedIndex = 0;
            if (isDeck)
            {
                plH.Visible = true;
                plL.Visible = true;
                plYZB.Visible = false;
            }
            else
            {
                plH.Visible = false;
                plL.Visible = false;
                plYZB.Visible = true;
                InitType();
            }
        }
        private void InitType()
        {

            var values = Enum.GetValues(typeof(FDEE.Model.eSubType));
            int index = 0;


            foreach (var item in values)
            {
                cbHeight.Items.Add(item);
                ++index;
            }

            if (cbHeight.Items.Count > 2)
            {
                cbHeight.SelectedIndex = 1;
            }
            cbNum.SelectedIndex = 0;

           
        }
        private void btnConfim_Click(object sender, EventArgs e)
        {
            try
            {
                title = cbLine.Text;
                pierParas = pierPara.Text;
                if (string.IsNullOrWhiteSpace(txtW.Text))
                {
                    MessageBox.Show("请设置W值！", "提示");
                    return;
                }
                width = double.Parse(txtW.Text);
                pierParas = pierPara.Text;
                if (isDec)
                {
                    if (string.IsNullOrWhiteSpace(txtL.Text))
                    {
                        MessageBox.Show("请设置L值！", "提示");
                        return;
                    }
                    length = double.Parse(txtL.Text);
                    if (string.IsNullOrWhiteSpace(pierPara.Text))
                    {
                        MessageBox.Show("请按格式输入墩柱参数", "提示");
                        return;
                    }
                }
                title = cbLine.Text;
                eHeightType = (FDEE.Model.eSubType)cbHeight.SelectedIndex; // 墩高分类
                hasHole = ckHasHole.Checked;

                NumHalfEJ = int.Parse(txtnumEj.Text);
                NumLink = int.Parse(txtnumLink.Text);
                NumHole = int.Parse(txtHoleNum.Text);
                
                typeNum = int.Parse(cbNum.Text);
                totalNum = int.Parse(txtTotal.Text);
            }
            catch
            {

            }
            this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }


    }
}
